package com.xh.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xh
 * @date 2022年09月01日 16:48
 */
@RestController
public class Controller {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @GetMapping("/getFromMaster")
    public List getFromMaster() {
        return jdbcTemplate.queryForList("SELECT * FROM `dept`");
    }

    @GetMapping("/getFromSlave")
    @DS("slave")
    public List getFromSlave() {
        return jdbcTemplate.queryForList("SELECT * FROM `users`");
    }
}
